# List all NMF models
nmfModel()
# or list only the built-in models
nmfModel(builtin.only=TRUE)
# create a NMF object based on one random matrix: the missing matrix is deduced
# Note this only works when using factory method NMF
n <- 50; r <- 3;
w <- rmatrix(n, r)
nmfModel(W=w)
# create a NMF object based on random (compatible) matrices
p <- 20
h <- rmatrix(r, p)
mod <- nmfModel(W=w, H=h)
# For example use the model as a seed (initialization) for the default NMF algorithm to fit a target matrix
V <- rmatrix(n, p)
nmf(V, seed=mod)
# create an empty NMF model compatible with a given target matrix
nmfModel(V)
# create a r-ranked NMF model with a given target matrix
nmfModel(r, V)
# create a r-ranked NMF model with a given target dimensions n x p as a 2-length vector
nmfModel(r, c(n,p)) # directly
nmfModel(r, dim(V)) # or from an existing matrix <=> nmfModel(r, V)
# or alternatively passing each dimension separately
nmfModel(r, n, p)
# create a NMF object based on incompatible matrices: generate an error
h <- matrix(runif((r+1)*p), r+1, p)
new('NMFstd', W=w, H=h)
# same thing using the factory method: dimensions are corrected and a warning
# is thrown saying that the dimensions used are reduced
nmfModel(W=w, H=h)
Run the code above in your browser using DataLab